package 懒惰拼字赛;

import java.util.HashSet;
import java.util.Scanner;

public class Main {
    static int mol = 1000000007;

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int T = in.nextInt();
        for (int cases = 1; cases <= T; cases++) {
            String s = in.next();
            int n = s.length();
            HashSet<Character> set = new HashSet<>();
            long res = 1;
            for (int i = 0; i < n; i++) {
                set.clear();
                for (int j = Math.max(0, i - 1); j <= Math.min(i + 1, n - 1); j++) {
                    set.add(s.charAt(j));
                }
                res = res * set.size() % mol;
            }
            System.out.printf("Case #%d: %d\n", cases, res);
        }
    }
}
